<template>
  <avue-crud ref="crud"
             :data="data"
             :option="option"></avue-crud>
  <div style="margin-top: 20px">
    <el-button @click="setCurrent(data[1])">选中第二行</el-button>
    <el-button @click="setCurrent()">取消选择</el-button>
  </div>
</template>
<script>
export default {
  data () {
    return {
      data: [
        {
          name: '张三',
          sex: '男'
        }, {
          name: '李四',
          sex: '女'
        }
      ],
      option: {
        highlightCurrentRow: true,
        column: [
          {
            label: '姓名',
            prop: 'name'
          }, {
            label: '性别',
            prop: 'sex'
          }
        ]
      }
    }
  },
  methods: {
    setCurrent (row) {
      this.$refs.crud.setCurrentRow(row);
    },
    handleCurrentRowChange (val) {
      this.$notify({
        showClose: true,
        message: '单选' + JSON.stringify(val),
        type: 'success',
      });
    }
  }
}
</script>